package com.jzsk.variable.center.zhengxin.controller;

import com.jzsk.variable.center.common.utils.buildjar.ClassInfo;
import com.jzsk.variable.center.common.utils.buildjar.ClassUtil;
import com.jzsk.variable.center.domain.dto.zxfield.CodeImplListRespDTO;
import com.jzsk.variable.center.domain.vo.ResponseVO;
import com.jzsk.variable.center.service.zxfield.ZxFieldService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@Api(tags = "征信字段管理")
@RequestMapping("/zxfield")
public class ZxFieldsController {

    @Resource
    ZxFieldService zxFieldService;

    @PostMapping("/codeImplList")
    @ApiOperation(value = "代码实现列表", notes = "代码实现列表")
    public ResponseVO<CodeImplListRespDTO> codeImplList() {
        List<ClassInfo> classInfoList = ClassUtil.getAllClasses("com.jzsk.variable.center.zhengxin.zxtzys.rules");
        List<String> classNames = classInfoList.stream().map(ClassInfo::getClassName).collect(Collectors.toList());
        return ResponseVO.success(CodeImplListRespDTO.builder()
                .codeImplList(classNames)
                .build());
    }

}
